<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCustomFieldsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('custom_fields', function (Blueprint $table) {
            $table->integer('id')->unique()->comment('id');
            $table->integer('business_type_id')->default(0)->comment('业务类型单据');
            $table->string('name',32)->default('')->comment('标识')->index();
            $table->string('label',100)->default('')->comment('显示名称');
            $table->tinyInteger('origin_type_id')->default(1)->comment('来源类型');
            $table->tinyInteger('widget_type_id')->default(1)->comment('组件类型');
            $table->integer('enum_id')->default(0)->comment('关联枚举');
            $table->tinyInteger('visibility_type_id')->default(1)->comment('可见度');
            $table->tinyInteger('is_store')->default(1)->comment('是否存储');
            $table->string('default')->default('')->comment('默认值');
            $table->text('describe')->comment('描述');
            $table->integer('relation_business_type_id')->default(0)->comment('关联业务类型');
            $table->integer('relation_field_id')->default(0)->comment('关联字段ID');
            $table->integer('index_field_id')->default(0)->comment('使用索引字段');
            $table->tinyInteger('status_type_id')->default(10)->comment('状态');
            $table->tinyInteger('is_tenant_update')->default(0)->comment('租户是否改动');
            $table->integer('created_id')->default(0)->comment('创建人');
            $table->integer('updated_id')->default(0)->comment('修改人');
            $table->integer('created_at')->default(0)->comment('创建时间');
            $table->integer('updated_at')->default(0)->comment('修改时间');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('custom_fields');
    }
}
